const host = ''
const baseUrl = "http://localhost:8088"
// const baseUrl = "https://zandequan.com"

const appId = 'wxb3c416164cc2e4d5'
const wxRequest = (params, url) => {
  wx.showToast({
    title: '加载中',
    icon: 'loading'
  })
  wx.request({
    url: url,
    method: params.method || 'GET',
    data: params.data || {},
    header: {
      'Content-Type': 'application/json',
      'appId': appId
    },
    success: (res) => {
      params.success && params.success(res)
      wx.hideToast()
    },
    fail: (res) => {
      params.fail && params.fail(res)
    },
    complete: (res) => {
      params.complete && params.complete(res)
    }
  })
}
//传地址
// const purl = (params) => wxRequest(params, params.url)

//联赛总数据
// const league = (params) => wxRequest(params, 'http://dca.qiumibao.com/shuju/public/index.php?_url=/index/league')

//完赛
// const record = (params) => wxRequest(params, 'http://m.zhibo8.cc/json/record/'+params.time+'.htm')


//轮播图
// const carousel = (params) => wxRequest(params, 'https://api.3g.ifeng.com/'+params.type)

//新闻文章&&专题
// const article = (params) => wxRequest(params, 'https://api.iclient.ifeng.com/'+params.type)


// 最新评论
// const newcomment = (params) => wxRequest(params, 'http://comment.ifeng.com/get?job=1&order=DESC&orderBy=create_time')

// 热评
// const hotcomment = (params) => wxRequest(params, 'http://comment.ifeng.com/get?job=1&orderby=uptimes&order=DESC')

//首页新闻视频
// const videoitem = (params) => wxRequest(params, 'https://api.iclient.ifeng.com/api_phoenixtv_details?guid='+params.guid)

////////////////////
//新闻文章
const articleInfo = (params) => wxRequest(params, baseUrl + '/article/wxInfo/' + params.data.id)
//新闻
const news = (params) => wxRequest(params, baseUrl + '/article/wxlist')
//类目
const category = (params) => wxRequest(params, baseUrl + '/category/wxlist')

//类目
const mediaList = (params) => wxRequest(params, baseUrl + '/media/wxlist')

//首页轮播图
const carouselList = (params) => wxRequest(params, baseUrl + '/carousel/wxlist');

//获取模板
const templateInfo = (params) => wxRequest(params, baseUrl + '/categorytemplate/wxInfo/' + params.data.id);
module.exports = {
  // purl,
  // league,
  // record,
  // carousel,
  // article,
  // hotcomment,
  // newcomment,
  // videoitem,
  news,
  articleInfo,
  category,
  mediaList,
  carouselList,
  templateInfo
}


